<template>
    <div>
        <el-form :model="ruleForm" ref="ruleForm"  :label-position="labelPosition" label-width="120px" class="demo-ruleForm">
            <div class="container">
                <h3>客户信息</h3>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="客户名称：">
                            {{ruleForm.clientName}}
                        </el-form-item>
                        <el-form-item label="联系方式："> 
                            {{ruleForm.phone}}
                        </el-form-item>
                        <el-form-item label="详细地址：">
                            {{ruleForm.address}}
                        </el-form-item>
                    </el-col>
                    <el-col :span="10">
                        <el-form-item label="联系人姓名：">
                            {{ruleForm.userName}}
                        </el-form-item>
                        <el-form-item label="所在地区：">
                            {{ruleForm.area}}
                        </el-form-item>
                        <el-form-item label="对接人：">
                            {{ruleForm.meetPeople}}
                        </el-form-item>
                    </el-col>
                </el-row>
            </div>
            <div class="container" style="margin-top:20px;">
                <h3>订货信息</h3>
                 <el-table
                :data="tableData"
                border
                ref="multipleTable"
                header-cell-class-name="table-header"
                style="margin-top:20px;"
            >
                <el-table-column prop="supplierName" sortable label="时间"></el-table-column>
                <el-table-column prop="area" sortable label="品名"></el-table-column>
                <el-table-column prop="userName" sortable label="规格"></el-table-column>
                <el-table-column prop="phone" sortable label="数量"></el-table-column>
                <el-table-column prop="phone" sortable label="单位"></el-table-column>
            </el-table>
            <el-pagination layout="total, prev, pager, next, jumper" :page-size="pagesize" :current-page.sync="currentPage"  @current-change="handleCurrentChange" :total="total" style="margin-top:20px"></el-pagination>
            </div>
			<el-form-item class="footerFixed" label-width="0px">
			    <el-button @click="backPage">返回</el-button>
			</el-form-item>
        </el-form>
    </div>
</template>

<script>
    import {client_findById} from '@/request/api'
	import {CodeToText} from 'element-china-area-data'
    export default {
        data(){
            return{
                total:0,
                pagesize:10,
                currentPage:1,
                ruleForm:{},
                tableData:[],
                id:'',
                labelPosition:'right'
            }
        },
        mounted(){
            this.id = this.$route.query.id
            this.init()
        },
        methods:{
			backPage(){
				this.$router.go(-1)
			},
            init(){

                client_findById(this.id).then((res)=>{  
                    this.ruleForm = res.data
					var list = this.ruleForm.area.split(",")
					var arr = ""
					for (let k = 0; k < list.length; k++) {
					    arr += CodeToText[list[k]] + "/"   
					}  
					  this.ruleForm.area = arr.substr(0,arr.length-1)
                })
            },
            handleCurrentChange(){

            }
        }
    }
</script>

<style scoped>
 .el-pagination{
    text-align: center;
} 
</style>